home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-05-01 | 22.2 KB | 865 lines | [TEXT/MPS ] |
- // UTEDocument.cp
- // Copyright © 1990-1991 by Apple Computer, Inc. All rights reserved.
-
- #ifndef __GEOMETRY__
- #include <Geometry.h>
- #endif
-
- #ifndef __ULIST__
- #include <UList.h>
- #endif
-
- #ifndef __ALIASES__
- #include <Aliases.h>
- #endif
-
- #ifndef __UFILE__
- #include <UFile.h>
- #endif
-
- #ifndef __EDITIONS__
- #include <Editions.h>
- #endif
-
- #ifndef __DIALOGS__
- #include <Dialogs.h>
- #endif
-
- #ifndef __UAPPLICATION__
- #include <UApplication.h>
- #endif
-
- #ifndef __UPRINTHANDLER__
- #include <UPrintHandler.h>
- #endif
-
- #ifndef __BALLOONS__
- #include <Balloons.h>
- #endif
-
- #ifndef __UVIEW__
- #include <UView.h>
- #endif
-
- #ifndef __UWINDOW__
- #include <UWindow.h>
- #endif
-
- #ifndef __UTEVIEW__
- #include <UTEView.h>
- #endif
-
- #ifndef __PRINTING__
- #include <Printing.h>
- #endif
-
- #ifndef __UPRINTING__
- #include <UPrinting.h>
- #endif
-
- #ifndef __UFAILURE__
- #include <UFailure.h>
- #endif
-
- #ifndef __UMACAPPUTILITIES__
- #include <UMacAppUtilities.h>
- #endif
-
- #ifndef __MENUS__
- #include <Menus.h>
- #endif
-
- #ifndef __UMENUMGR__
- #include <UMenuMgr.h>
- #endif
-
- #ifndef __UPATCH__
- #include <UPatch.h>
- #endif
-
- #ifndef __UMACAPPGLOBALS__
- #include <UMacAppGlobals.h>
- #endif
-
- #ifndef __UMEMORY__
- #include <UMemory.h>
- #endif
-
- #ifndef __UERRORMGR__
- #include <UErrorMgr.h>
- #endif
-
- #ifndef __FONTS__
- #include <Fonts.h>
- #endif
-
- #ifndef __RESOURCES__
- #include <Resources.h>
- #endif
-
- #ifndef __TOOLUTILS__
- #include <ToolUtils.h>
- #endif
-
- #ifndef __PACKAGES__
- #include <Packages.h>
- #endif
-
- #ifndef __PICKER__
- #include <Picker.h>
- #endif
-
- #ifndef __ERRORS__
- #include <Errors.h>
- #endif
-
- #ifndef __UTEDOCUMENT__
- #include <UTEDocument.h>
- #endif
-
- #ifndef __UTECOMMANDS__
- #include <UTECommands.h>
- #endif
-
- #ifndef __UVIEWSERVER__
- #include <UViewServer.h>
- #endif
-
- //--------------------------------------------------------------------------------------------------
- TextSpecs gDefaultSpecs; // ??? used but never initialized below !!!
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocOpen
- pascal void TTEDocument::Initialize(void) // override
- {
- inherited::Initialize();
- fDocText = NULL;
- fElements = NULL;
- fStyles = NULL;
- fTEView = NULL;
- fTextSpecs = gDefaultSpecs;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocOpen
-
- pascal void TTEDocument::ITEDocument(TFile* itsFile,
- const OSType itsFileType,
- const OSType itsCreator,
- const OSType itsScrapType,
- Boolean usesDataFork,
- Boolean usesRsrcFork,
- Boolean keepsDataOpen,
- Boolean keepsRsrcOpen)
- {
- this->IFileBasedDocument(itsFile, itsFileType, itsCreator, itsScrapType, usesDataFork, usesRsrcFork, keepsDataOpen, keepsRsrcOpen);
-
- fDocText = NewPermHandle(0);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocClose
-
- pascal void TTEDocument::Free(void) // override
- {
- fDocText = DisposeIfHandle(fDocText);
-
- inherited::Free();
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocNonRes
-
- pascal void TTEDocument::ChangeBackColor(const RGBColor& newColor)
- {
- GrafPtr oldPort;
- TView * itsRootView;
-
- //??? Is this right? Should we set the background color even if
- // the view isn't in a window yet?
- GetPort(oldPort);
- SetPort((*fTEView->fHTE)->inPort);
- RGBBackColor(newColor);
- itsRootView = fTEView->GetRootView();
- if (itsRootView)
- itsRootView->ForceRedraw();
- SetPort(oldPort);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocOpen
-
- pascal void TTEDocument::DoInitialState(void) // override
- {
- fTextSpecs = gDefaultSpecs;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocOpen
-
- pascal void TTEDocument::DoMakeViews(Boolean forPrinting)// override
-
- {
- TView * aView;
- TStdPrintHandler * aHandler;
-
- if (forPrinting)
- // We're only finder printing--don't need a window, just the view being printed
- aView = gViewServer->DoCreateViews(this, NULL, kViewRsrcID, gZeroVPt);
- else
- aView = gViewServer->NewTemplateWindow(kWindowRsrcID, this);
-
- aView = aView->FindSubView('TEVW');
- fTEView = (TTEView *)aView; // Must cast because FindSubView returns TView
- aHandler = new TStdPrintHandler;
- aHandler->IStdPrintHandler(this, // its document
- fTEView, // its view
- !kSquareDots, // does not have square dots
- kFixedSize, // horzontal page size is fixed
- !kFixedSize); // vertical page size is variable (could be
- // set to true on non-style TE systems)
-
- this->ShowReverted();
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocSelCommand
-
- void TTEDocument::DoJustChange(CmdNumber aCmdNumber)
- {
- short newJust;
- TJustCommand * aJustChange;
-
- switch (aCmdNumber)
- {
- case cJustSystem:
- newJust = teFlushDefault;
- break;
-
- case cJustForceLeft:
- newJust = teFlushLeft;
- break;
-
- case cJustCenter:
- newJust = teCenter;
- break;
-
- case cJustRight:
- newJust = teFlushRight;
- break;
- };
- aJustChange = new TJustCommand;
- aJustChange->IJustCommand(fTEView, newJust);
- fTextSpecs.theJustification = newJust;
- this->PostCommand(aJustChange);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocSelCommand
-
- void TTEDocument::DoStyleChange(CmdNumber aCmdNumber)
- {
- TextStyle newStyle;
-
- switch (aCmdNumber)
- {
- case cBold:
- newStyle.tsFace = bold;
- break;
-
- case cItalic:
- newStyle.tsFace = italic;
- break;
-
- case cUnderline:
- newStyle.tsFace = underline;
- break;
-
- case cOutline:
- newStyle.tsFace = outline;
- break;
-
- case cShadow:
- newStyle.tsFace = shadow;
- break;
-
- case cCondense:
- newStyle.tsFace = condense;
- break;
-
- case cExtend:
- newStyle.tsFace = extend;
- break;
- }
- if ((newStyle.tsFace * fTextSpecs.theTextFace) == newStyle.tsFace)
- fTextSpecs.theTextFace -= newStyle.tsFace;
- else
- fTextSpecs.theTextFace += newStyle.tsFace;
- this->PostCommand(fTEView->DoMakeStyleCommand(newStyle, cStyleChange, doFace + doToggle));
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocSelCommand
-
- void TTEDocument::DoColTextChange()
- {
- TextStyle newStyle;
- RGBColor aColor;
- Str255 promptString;
-
- aColor = fTextSpecs.theTextColor;
- GetIndString(promptString, kPromptsRsrcID, kColTextPrompt);
- if (GetColor(Point(64, 64), promptString, aColor, newStyle.tsColor))
- {
- fTextSpecs.theTextColor = newStyle.tsColor;
- this->PostCommand(fTEView->DoMakeStyleCommand(newStyle, cColorChange, doColor + doToggle));
- }
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocSelCommand
-
- void TTEDocument::DoColBackChange()
- {
- TextStyle newStyle;
- RGBColor aColor;
- Str255 promptString;
-
- aColor = fTextSpecs.theBackColor;
- GetIndString(promptString, kPromptsRsrcID, kColBackPrompt);
- if (GetColor(Point(64, 64), promptString, aColor, newStyle.tsColor))
- {
- fTextSpecs.theBackColor = newStyle.tsColor;
- this->ChangeBackColor(newStyle.tsColor);
- }
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocSelCommand
-
- void TTEDocument::InstallChangedDeterminer(VHSelect vhs,
- SizeDeterminer sd)
- {
- if (sd != fTEView->fSizeDeterminer[vhs])
- {
- fTEView->fSizeDeterminer[vhs] = sd;
-
- // If we changed the horizontal size determiner,
- // we must ask the TTEView to recompute the TE rectangles.
- if (vhs == hSel)
- {
- if (sd == sizeSuperView)
- fTEView->SuperViewChangedSize(gZeroVPt, TRUE);// Don't care about deltas
- else if (sd == sizePage)
- fTEView->DoPagination();
- }
-
- fTEView->AdjustSize();
- fTEView->ForceRedraw();
- }
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocSelCommand
-
- void TTEDocument::DoWidthChange(CmdNumber aCmdNumber)
- {
- SizeDeterminer sd;
-
- if (aCmdNumber == cWidthSuperView)
- sd = sizeSuperView;
- else if (aCmdNumber == cWidthOnePage)
- sd = sizePage;
- else
- sd = sizeFixed;
-
- // NB: The following is not undoable in the
- // current version
- this->InstallChangedDeterminer(hSel, sd);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocSelCommand
-
- void TTEDocument::DoHeightChange(CmdNumber aCmdNumber)
- {
- SizeDeterminer sd;
-
- switch (aCmdNumber)
- {
- case cHeightSuperView:
- sd = sizeSuperView;
- break;
-
- case cHeightPages:
- sd = sizeFillPages;
- break;
-
- case cHeightText:
- sd = sizeVariable;
- break;
-
- case cHeightConst:
- sd = sizeFixed;
- break;
- }
-
- // NB: The following is not undoable in the
- // current version
- this->InstallChangedDeterminer(vSel, sd);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocSelCommand
-
- pascal void TTEDocument::DoMenuCommand(CmdNumber aCmdNumber)// override
- {
- Str255 aName;
- short menu;
- short item;
- TextStyle newStyle;
-
- CmdToMenuItem(aCmdNumber, menu, item);
-
- if (menu == mFont)
- {
- GetItem(GetMHandle(menu), item, aName);
- GetFNum(aName, newStyle.tsFont);
- fTextSpecs.theTextFont = aName;
- this->PostCommand(fTEView->DoMakeStyleCommand(newStyle, cFontChange, doFont + doToggle));
- }
- else if ((aCmdNumber > cSizeBase) && (aCmdNumber <= cSizeMax))
- {
- newStyle.tsSize = (short)(aCmdNumber - cSizeBase);
- fTextSpecs.theTextSize = newStyle.tsSize;
- this->PostCommand(fTEView->DoMakeStyleCommand(newStyle, cSizeChange, doSize + doToggle));
- }
- else
- switch (aCmdNumber)
- {
- case cSizeOther:
- // as yet unsupported
- break;
-
- case cSizeGrow:
- case cSizeShrink:
- if (aCmdNumber == cSizeGrow)
- {
- newStyle.tsSize = kRelSizeAmount;
- fTextSpecs.theTextSize += kRelSizeAmount;
- }
- else
- {
- newStyle.tsSize = -kRelSizeAmount;
- fTextSpecs.theTextSize -= kRelSizeAmount;
- }
- this->PostCommand(fTEView->DoMakeStyleCommand(newStyle, cSizeChange, doSize + addSize + doToggle));
- break;
-
- case cJustForceLeft:
- case cJustCenter:
- case cJustRight:
- case cJustSystem:
- this->DoJustChange(aCmdNumber);
- break;
-
- case cPlainText:
- newStyle.tsFace = 0;
- fTextSpecs.theTextFace = 0;
- this->PostCommand(fTEView->DoMakeStyleCommand(newStyle, cStyleChange, doFace));
- break;
-
- case cBold:
- case cItalic:
- case cUnderline:
- case cOutline:
- case cShadow:
- case cCondense:
- case cExtend:
- this->DoStyleChange(aCmdNumber);
- break;
-
- case cColorText:
- this->DoColTextChange();
- break;
-
- case cColorBackground:
- this->DoColBackChange();
- break;
-
- case cWidthSuperView:
- case cWidthView:
- case cWidthOnePage:
- this->DoWidthChange(aCmdNumber);
- break;
-
- case cHeightSuperView:
- case cHeightPages:
- case cHeightText:
- case cHeightConst:
- this->DoHeightChange(aCmdNumber);
- break;
-
- default:
- inherited::DoMenuCommand(aCmdNumber);
- break;
- }
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocWriteFile
-
- pascal void TTEDocument::DoNeedDiskSpace(TFile* itsFile,
- long& dataForkBytes,
- long& rsrcForkBytes)// override
- {
- TEStyleHandle styles;
- STHandle elements;
-
- dataForkBytes += GetHandleSize(fDocText);
-
- rsrcForkBytes += kPrintInfoSize + kRsrcTypeOverhead + kRsrcOverhead;
-
- if ((fTEView->fStyleType == kWithStyle) && (fTEView->fHTE))
- {
- fTEView->ExtractStyles(styles, elements);
- rsrcForkBytes += GetHandleSize((Handle)styles) + kRsrcTypeOverhead + kRsrcOverhead + GetHandleSize((Handle)elements) + kRsrcTypeOverhead + kRsrcOverhead;
- }
-
- rsrcForkBytes += sizeof(TextSpecs) + kRsrcTypeOverhead + kRsrcOverhead;
-
- // Get resource file overhead
- inherited::DoNeedDiskSpace(itsFile, dataForkBytes, rsrcForkBytes);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocReadFile
-
- pascal void TTEDocument::DoRead(TFile* aFile, Boolean forPrinting) // override
- {
- long numChars;
- TextSpecsHdl hTextSpecs;
- Handle hPrintInfo;
-
- // Read in the print info
- inherited::DoRead(aFile, forPrinting);
-
- FailOSErr(aFile->GetDataLength(numChars)); // Read in the text
-
- if (numChars > kUnlimited) // The file may have been created by…
- {
- // …someone else - limit it to 32K!
- gApplication->ShowError(0, msgAlert + kFileTooBig);
- numChars = kUnlimited;
- }
-
- SetHandleSize(fDocText, numChars);
- FailMemError();
- FailOSErr(aFile->ReadData(*fDocText, numChars));
-
- fStyles = // Read in the TEStyleRec
- (TEStyleHandle)GetResource(kTextStyleRsrcType, kStylesRsrcID);
- if (fStyles != NULL)
- DetachResource((Handle)fStyles);
-
- fElements = // Read in the STElement array
- (STHandle)(GetResource(kTextStyleRsrcType, kElementsRsrcID));
- if (fElements != NULL)
- DetachResource((Handle)fElements);
-
- hTextSpecs = // Read the text specs resource
- (TextSpecsHdl)GetResource(kTextSpecsRsrcType, kTextSpecsRsrcID);
- if (hTextSpecs != NULL)
- fTextSpecs = **hTextSpecs;
- else
- this->DoInitialState();
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocRes
-
- pascal void TTEDocument::DoSetupMenus(void) // override
- {
- Boolean checkPlain;
- Boolean checkFont;
- Boolean specChange;
- short just;
- short aMode;
- Style aFace;
- SizeDeterminer sd;
- MenuHandle aMenuHandle;
- Str255 aName;
- TextStyle aStyle;
- short theFont;
- short startOfSelection,
- endOfSelection;
-
- inherited::DoSetupMenus();
-
- startOfSelection = (*fTEView->fHTE)->selStart;
- endOfSelection = (*fTEView->fHTE)->selEnd;
-
- aMode = doFace;
- checkPlain = fTEView->ContinuousStyle(startOfSelection, endOfSelection, aMode, aStyle) && (aStyle.tsFace == 0);
-
- aMode = doAll;
- aStyle.tsFace = bold | italic | underline | outline | shadow | extend | condense;
-
- specChange = fTEView->ContinuousStyle(startOfSelection, endOfSelection, aMode, aStyle);
- checkFont = ((aMode & doFont) != 0);
-
- aMenuHandle = GetMHandle(mFont);
- // If specs have changed && EITHER an old-style record || the font's continuous - Ed.
- specChange = (fTEView->fSpecsChanged && checkFont);
-
- GetFontName(aStyle.tsFont, aName); // Get real font number in case tsFont is
- GetFNum(aName, theFont); // …the system or application font.
- for (short item = 1; item <= CountMItems(aMenuHandle); ++item)
- {
- // There can be more than 31 menu entries with scrolling menus, but trying to enable
- // an item with number > 31 is bad news. If the menu itself is enabled (which it
- // will be in MacApp if any of the first 31 items is enabled), then the extras
- // will always be enabled.
- if (item <= 31)
- EnableItem(aMenuHandle, item);
- if (checkFont)
- {
- short fnt;
-
- GetItem(aMenuHandle, item, aName);
- GetFNum(aName, fnt);
- CheckItem(aMenuHandle, item, (fnt == theFont));
- }
- }
-
- sd = fTEView->fSizeDeterminer[hSel]; // Enable size determiner related menu items
- EnableCheck(cWidthSuperView, TRUE, (sd == sizeSuperView));
- EnableCheck(cWidthOnePage, TRUE, (sd == sizePage));
- EnableCheck(cWidthView, TRUE, (sd == sizeFixed));
-
- sd = fTEView->fSizeDeterminer[vSel];
- EnableCheck(cHeightSuperView, TRUE, (sd == sizeSuperView));
- EnableCheck(cHeightPages, TRUE, (sd == sizeFillPages));
- EnableCheck(cHeightText, TRUE, (sd == sizeVariable));
- EnableCheck(cHeightConst, TRUE, (sd == sizeFixed));
-
- just = fTEView->fJustification; // Enable justification related menu items
- EnableCheck(cJustSystem, TRUE, (just == teFlushDefault));
- EnableCheck(cJustForceLeft, TRUE, (just == teFlushLeft));
- EnableCheck(cJustCenter, TRUE, (just == teCenter));
- EnableCheck(cJustRight, TRUE, (just == teFlushRight));
-
- Enable(cStyle, TRUE); // Enable sub-menus
- Enable(cSize, TRUE);
- Enable(cFont, TRUE);
- Enable(cColor, (qNeedsColorQD || gConfiguration.hasColorQD));
-
- aFace = aStyle.tsFace;
- EnableCheck(cPlainText, TRUE, checkPlain); // Enable normal Style menu items
- EnableCheck(cBold, TRUE, bold & aFace);
- EnableCheck(cItalic, TRUE, italic & aFace);
- EnableCheck(cUnderline, TRUE, underline & aFace);
- EnableCheck(cOutline, TRUE, outline & aFace);
- EnableCheck(cShadow, TRUE, shadow & aFace);
- EnableCheck(cCondense, TRUE, condense & aFace);
- EnableCheck(cExtend, TRUE, extend & aFace);
-
- for (short c = cSizeMin; c <= cSizeMax; ++c)
- {
- Boolean checkSize;
-
- if (!(aMode & doSize))
- checkSize = FALSE;
- else
- checkSize = ((c - cSizeBase) == aStyle.tsSize);
-
- EnableCheck(c, TRUE, checkSize);
- if (fTEView->fSpecsChanged)
- {
- // if it _is_ styled and font is continuous
- // …and the size is a real one
- if ((aMode & doFont) && RealFont(aStyle.tsFont, c - cSizeBase))
- aFace = outline; // …then we outline it
- else
- aFace = 0;
- SetStyle(c, aFace);
- }
- }
-
- Enable(cSizeGrow, TRUE);
- Enable(cSizeShrink, TRUE);
-
- Enable(cColorText, (qNeedsColorQD || gConfiguration.hasColorQD));
- Enable(cColorBackground, (qNeedsColorQD || gConfiguration.hasColorQD));
-
- fTEView->fSpecsChanged = FALSE;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocWriteFile
-
- pascal void TTEDocument::DoWrite(TFile* aFile, Boolean makingCopy) // override
- {
- long numChars;
- TextSpecsHdl hTextSpecs;
- Handle tempHandle;
- TEStyleHandle styles;
- STHandle elements;
-
- // write out the print info
- inherited::DoWrite(aFile, makingCopy);
-
- // Write out the text
- numChars = GetHandleSize(fDocText);
- FailOSErr(aFile->WriteData(*fDocText, numChars));
-
- if (fTEView->fStyleType == kWithStyle)
- {
- fTEView->ExtractStyles(styles, elements);
- FailOSErr(HandToHand((Handle&)styles));
- AddResource((Handle)styles, kTextStyleRsrcType, kStylesRsrcID, "");
- FailResError();
- FailOSErr(HandToHand((Handle&)elements));
- AddResource((Handle)elements, kTextStyleRsrcType, kElementsRsrcID, "");
- FailResError();
- }
-
- // Write the text specification resource, after converting it to a handle
- hTextSpecs = (TextSpecsHdl)NewPermHandle(sizeof(TextSpecs));
- **hTextSpecs = fTextSpecs;
- AddResource((Handle)hTextSpecs, kTextSpecsRsrcType, kTextSpecsRsrcID, "");
- FailResError();
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocClose
-
- pascal void TTEDocument::FreeData(void) // override
- {
- SetHandleSize(fDocText, 0);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocRes
-
- pascal void TTEDocument::SetSpecStyle(void)
- {
- short theFont;
- TextStyle theTS;
- Str255 aStr255;
-
- aStr255 = fTextSpecs.theTextFont;
- GetFNum(aStr255, theFont);
- SetTextStyle(theTS, theFont, fTextSpecs.theTextFace, fTextSpecs.theTextSize, fTextSpecs.theTextColor);
- fTEView->SetOneStyle(0, 0, doAll, theTS, kDontRedraw);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocReadFile
-
- pascal void TTEDocument::ShowReverted(void) // override
- {
- RGBColor aColor;
-
- fTEView->StuffText(fDocText); // put in the text
- TESetSelect(0, 0, fTEView->fHTE);
- if (fStyles && fElements) // If we're able, stuff style info
- fTEView->StuffStyles(fStyles, fElements);
- else
- this->SetSpecStyle();
-
- if (qNeedsColorQD || gConfiguration.hasColorQD)
- {
- aColor = fTextSpecs.theBackColor;
- this->ChangeBackColor(aColor);
- }
- fTEView->SetJustification(fTextSpecs.theJustification, kDontRedraw);
- inherited::ShowReverted();
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocFields
-
- pascal void TTEDocument::Fields(TObject* obj) // override
-
- {
- obj->DoToField("TTEDocument", (Ptr)NULL, bClass);
- obj->DoToField("fDocText", (Ptr) & fDocText, bHandle);
- obj->DoToField("fTEView", (Ptr) & fTEView, bObject);
- obj->DoToField(" fTextSpecs", (Ptr)NULL, bClass);
- obj->DoToField(" theTextFont", (Ptr) & fTextSpecs.theTextFont, bString);
- obj->DoToField(" theTextFace", (Ptr) & fTextSpecs.theTextFace, bStyle);
- obj->DoToField(" theTextSize", (Ptr) & fTextSpecs.theTextSize, bInteger);
- obj->DoToField(" theTextColor", (Ptr) & fTextSpecs.theTextColor, bRGBColor);
- obj->DoToField(" theJustification", (Ptr) & fTextSpecs.theJustification, bInteger);
- obj->DoToField(" theBackColor", (Ptr) & fTextSpecs.theBackColor, bRGBColor);
-
- inherited::Fields(obj);
- }
-
- //******************************************************************************************
- // T J u s t C o m m a n d
- //******************************************************************************************
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocSelCommand
- pascal void TJustCommand::Initialize(void) // override
- {
- inherited::Initialize();
- fOldJust = teFlushDefault;
- fNewJust = teFlushDefault;
- fTEView = NULL;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocSelCommand
-
- pascal void TJustCommand::IJustCommand(TTEView* itsTEView,
- short itsNewJust)
- {
- this->ICommand(cJustChange, itsTEView->fDocument, itsTEView);
- fTEView = itsTEView;
- fOldJust = itsTEView->fJustification;
- fNewJust = itsNewJust;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocDoCommand
-
- pascal void TJustCommand::DoIt(void) // override
- {
- fTEView->SetJustification(fNewJust, kRedraw);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocDoCommand
-
- pascal void TJustCommand::RedoIt(void) // override
- {
- this->DoIt();
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocDoCommand
-
- pascal void TJustCommand::UndoIt(void) // override
- {
- fTEView->SetJustification(fOldJust, kRedraw);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment TEDocFields
-
- pascal void TJustCommand::Fields(TObject* obj) // override
-
- {
- obj->DoToField("TJustCommand", (Ptr)NULL, bClass);
- obj->DoToField("fTEView", (Ptr) & fTEView, bObject);
- obj->DoToField("fOldJust", (Ptr) & fOldJust, bInteger);
- obj->DoToField("fNewJust", (Ptr) & fNewJust, bInteger);
-
- inherited::Fields(obj);
- }
-
-
-